package com.qianlong.controller;

import com.qianlong.entity.User;
import com.qianlong.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/index")
    public String index(){
        return "login.html";
    }

    @PostMapping
    @RequestMapping("/insert")
    public int insert(User user){return userService.insert(user);}

    @DeleteMapping
    @RequestMapping("/delete")
    public int delete(String userId){return userService.delete(userId);}

    @PutMapping
    @RequestMapping("/update")
    public int update(User user){return userService.update(user);}

    @GetMapping
    @RequestMapping("/getOne")
    public User getOne(String userId){return userService.getOne(userId);}

    @GetMapping
    @RequestMapping("/getList")
    public List<User> getList(User user){return userService.getList(user);}

    @PostMapping
    @RequestMapping("/login")
    public int login(@ModelAttribute("user") User user){return userService.login(user);}

}
